<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
					xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
					xmlns:local="clr-namespace:EdiDialogs.FindReplace"
          
          xmlns:conv="clr-namespace:Edi.Core.Converters.MessageType;assembly=Edi.Core"
          xmlns:FRconv="clr-namespace:EdiDialogs.FindReplace.Converter"
          xmlns:behav="clr-namespace:Edi.Core.Behaviour;assembly=Edi.Core"
          xmlns:cmdLabel="clr-namespace:Util.Local;assembly=Util"
>
	<Style TargetType="{x:Type local:FindReplaceView}">
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Focusable" Value="False"/>
    <Setter Property="KeyboardNavigation.IsTabStop" Value="False" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:FindReplaceView}">
          <ControlTemplate.Resources>
            <FRconv:InverseBooleanConverter x:Key="InvertBooleanConv" />
            <FRconv:SearchScopeToInt x:Key="searchScopeToInt"/>
            <BooleanToVisibilityConverter x:Key="boolToVis" />
            <FRconv:BoolToInt x:Key="boolToInt"/>
            <conv:MsgTypeToResourceConverter x:Key="MsgTypeToResource" />

            <DataTemplate x:Key="FindPageTemplate">
              <StackPanel>
                <TextBlock Margin="3" Text="{x:Static cmdLabel:Strings.STR_FINDREPLACE_FINDLABEL}" />
                <ContentPresenter Content="{Binding }" />
                <StackPanel DataContext="{Binding DataContext}">

                  <TextBlock Text="{x:Static cmdLabel:Strings.STR_FINDREPLACE_SearchInLABEL}"
                             Margin="3"
                             Visibility="{Binding ShowSearchIn, Mode=OneWay, Converter={StaticResource boolToVis}}" />

                  <ComboBox SelectedIndex="{Binding SearchIn, Mode=TwoWay,Converter={StaticResource searchScopeToInt}}"
                            Margin="0 0 0 3" 
                            Visibility="{Binding ShowSearchIn, Converter={StaticResource boolToVis}}"
                            HorizontalAlignment="Stretch">
                    <ComboBoxItem Content="{x:Static cmdLabel:Strings.STR_FINDREPLACE_CURRENTDOC}" />
                    <ComboBoxItem Content="{x:Static cmdLabel:Strings.STR_FINDREPLACE_OPENDOCS}" />
                  </ComboBox>
                  <GroupBox Header="{x:Static cmdLabel:Strings.STR_FINDREPLACE_Options}" Padding="3">
                    <StackPanel>
                      <CheckBox Margin="1" Name="chkCaseSensitive" IsChecked="{Binding CaseSensitive, Mode=TwoWay}" Content="{x:Static cmdLabel:Strings.STR_FINDREPLACE_CaseSensitive}"     />
                      <CheckBox Margin="1" Name="chkSearchUp"      IsChecked="{Binding SearchUp, Mode=TwoWay}"      Content="{x:Static cmdLabel:Strings.STR_FINDREPLACE_SearchBackWard}"    />
                      <CheckBox Margin="1" Name="chkWholeWord"     IsChecked="{Binding WholeWord, Mode=TwoWay}"     Content="{x:Static cmdLabel:Strings.STR_FINDREPLACE_MatchWholeWord}"    />
                      <CheckBox Margin="1" Name="chkRegex"         IsChecked="{Binding UseRegEx, Mode=TwoWay}"      Content="{x:Static cmdLabel:Strings.STR_FINDREPLACE_RegularExpression}" />
                      <CheckBox Margin="1" Name="chkWildcards"     IsChecked="{Binding UseWildcards, Mode=TwoWay}"  Content="{x:Static cmdLabel:Strings.STR_FINDREPLACE_Wildcards}"         />
                    </StackPanel>
                  </GroupBox>
                </StackPanel>
              </StackPanel>
            </DataTemplate>
          </ControlTemplate.Resources>
            <Border Background="{TemplateBinding Background}"
							BorderBrush="{TemplateBinding BorderBrush}"
							BorderThickness="{TemplateBinding BorderThickness}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
            <Grid>
              <TabControl Name="tabMain" Height="Auto" BorderThickness="{Binding AllowReplace,  Converter={StaticResource boolToInt}}">
                <TabItem Header="{x:Static cmdLabel:Strings.STR_FIND_BUTTON_CAPTION}" Name="tabFind" IsSelected="{Binding ShowAsFind}"
                         ContentTemplate="{StaticResource FindPageTemplate}"
                         Visibility="{Binding AllowReplace, Converter={StaticResource boolToVis}}">
                  <StackPanel>
                    <ComboBox Text="{Binding TextToFind, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                            IsEditable="True" 
                            Margin="3"
                            Name="PART_TxtFind"
                            behav:FocusExtension.IsFocused="{Binding IsTextToFindFocused}"
                            ItemsSource="{Binding FindHistory}"/>
                    <Button Content="{x:Static cmdLabel:Strings.STR_FINDREPLACE_FINDNEXT}"
                            MinHeight="27"
                            Command="{Binding FindCommand}"
                            Margin="3" IsDefault="True" HorizontalAlignment="Right"/>
                  </StackPanel>
                </TabItem>
                <TabItem Header="{x:Static cmdLabel:Strings.STR_REPLACE_BUTTON_CAPTION}" Name="tabReplace"
                         IsSelected="{Binding ShowAsFind, Converter={StaticResource InvertBooleanConv}}"
                         ContentTemplate="{StaticResource FindPageTemplate}"
                         Visibility="{Binding AllowReplace, Converter={StaticResource boolToVis}}">
                  <StackPanel>
                    <ComboBox Text="{Binding TextToFind, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                            IsEditable="True" 
                            Margin="3"
                            Name="PART_TxtFind2"
                            behav:FocusExtension.IsFocused="{Binding IsTextToFindInReplaceFocused}"
                            ItemsSource="{Binding FindHistory}"/>

                    <TextBlock Margin="3" Text="{x:Static cmdLabel:Strings.STR_FINDREPLACE_ReplaceWith}" />
                    <ComboBox Text="{Binding ReplacementText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                              IsEditable="True" 
                              Margin="3"
                              Name="PART_TxtReplace"
                              ItemsSource="{Binding ReplaceHistory}"/>

                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                      <Button Content="{x:Static cmdLabel:Strings.STR_FINDREPLACE_FINDNEXT}"
                              Command="{Binding FindCommand}"
                              IsDefault="True" Margin="3" HorizontalAlignment="Right"
                              MinHeight="27" />
                      
                      <Button Content="{x:Static cmdLabel:Strings.STR_FINDREPLACE_Replace}"
                              Command="{Binding ReplaceCommand}"
                              Margin="3" HorizontalAlignment="Right" />

                      <Button Command="{Binding ReplaceAllCommand}"
                              Content="{x:Static cmdLabel:Strings.STR_FINDREPLACE_ReplaceAll}" Margin="3"
                              HorizontalAlignment="Right" MinHeight="27" />
                    </StackPanel>
                  </StackPanel>
                </TabItem>
              </TabControl>
            </Grid>
          </Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

</ResourceDictionary>